n3ilfandomcom-20200214-history
Linux Tips
See also: Windows Tips See also: Cisco Tips See also: Misc Tips __TOC__ =General (any distro)= Make sure you check out these tips How to automatically restart a daemon *Put this in crontab * */4 * * * /bin/pidof mythbackend >/dev/null || /etc/rc.d/mythbackend start How to rsync a whole linux box rsync -avH --numeric-ids --devices --specials --stats How to make encrypted tarballs tar czvf - |gpg -r user@example.com --encrypt > archive.tar.gz.gpg To decrypt: gpg --decrypt archive.tar.gz.gpg |tar xzvf - How to find out which process has a port open sudo netstat -tulp How to forward ports with ssh ssh -q -f -N -g -L :: How to multiplex through an ssh session Connect master: ssh -M -S ~/.ssh/ctl-%r-%h-%p user@somehost.com Connect slave: ssh -S ~/.ssh/ctl-%r-%h-%p user@somehost.com To automate it, add an entry for this host in ~/.ssh/config: Host somehost.com ControlPath ~/.ssh/ctl-%r-%h-%p ControlMaster auto Host *''' can be used to match all hosts. If you want to be asked to create a master session, use: ControlMaster autoask How to configure Sendmail to route to an smtp server Edit /etc/sendmail.mc: define(`SMART_HOST’, `esmtp:smtp.somehost.com‘)dnl If you need to use a port other than 25, add: define(`RELAY_MAILER_ARGS', `IPC $h 8080')dnl Run m4: m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf Restart Sendmail: /etc/init.d/sendmail restart How to rip a dvd with mencoder nice -n 18 mencoder dvd:// -alang en -vf scale -zoom -xy 640 \ -o -oac mp3lame -lameopts abr:br=192 \ -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1200:threads=2 How to encode video for ipod Get podencoder: http://diveintomark.org/public/2006/08/podencoder for i in *; do podencoder "$i" -o ~/ipodvids/; done How to get file/dir names right in grip %A - %d/%t - %A - %d - %n.%x How to unzip a whole bunch of zips into their own dirs in 1 command for i in *.zip; do mkdir `basename $i .zip`; unzip -d `basename $i .zip` $i; done How to configure a bttv card First of all, you need to tell the bttv what type of capture card you have. In gentoo, you need to create a file /etc/modules.d/bttv My card is a Lifeview Flyvideo 2000 which is card 54, so I add a line like so: options bttv card=54 How to stream with VLC vlc v4l:/dev/video:channel=1:norm=pal –sout #transcode{vcodec=mp4v,acodec=vorbis,vb=1024,ab=192}:\ standard{access=http,mux=ogg,url=10.10.10.11:8080}’ If you want to watch the stream as well, use this command: vlc v4l:/dev/video:channel=1:norm=pal –sout ‘#duplicate{dst=display,dst=”transcode\ {vcodec=mp4v,acodec=vorbis,vb=1024,ab=192}:standard{access=http,mux=ogg,url=10.10.10.11:8080}”}’ How to use sudo with no password '''This is a dumb idea. Don't do it! *run 'visudo', and add: %wheel ALL=(ALL) NOPASSWD: ALL How to convert flac to mp3 gst-launch-0.10 filesrc location= ! decodebin ! lame bitrate=256 ! filesink location= How to create SAMBA machine accounts useradd -d / -s /bin/false $ passwd -l $ smbpasswd -a -m $ How to map windows groups to unix groups on a SAMBA PDC rm /var/cache/samba/group_mapping.tdb net groupmap modify ntuser=”Domain Admins” unixgroup=wheel net groupmap modify ntuser=”Domain User” unixgroup=users How to get date & time in fluxbox session.screen0.strftimeFormat: %a %d %b, %k:%M How to rename network interfaces Put in /etc/udev/rules.d/05-net.rules SUBSYSTEM "net", ATTRS{address} "01:23:45:67:89:ab", NAME="lan0" SUBSYSTEM "net", ATTRS{address} "cd:ef:01:23:45:67", NAME="wlan0" Big important NOTE: The letters (a-f) in the MAC address must be lowercase! Otherwise it won't work. How to use openvpn *On the Server user nobody group nogroup ca ca.crt cert server.crt key server.key dh dh1024.pem tls-server duplicate-cn plugin /usr/lib/openvpn/openvpn-auth-pam.so system-auth client-cert-not-required username-as-common-name dev tun proto tcp port 443 server 10.10.10.0 255.255.255.0 comp-lzo keepalive 10 30 *On the client client dev tun proto tcp remote 443 nobind persist-key persist-tun ca /etc/openvpn/ca.crt comp-lzo *On linux you can store the username/password: auth-user-pass /etc/openvpn/secret chmod 600 /etc/openvpn/secret *Pushing default routes etc (to redirect all traffic via VPN) push "redirect-gateway" push "dhcp-option DNS " push "dhcp-option DNS " push "route " =Ubuntu (also debian)= How to get optional libraries for things apt-get build-dep Using package selections Dump installed packages to a file sudo dpkg --get-selections > packages Set selections from a file sudo dpkg --set-selections < packages Hold back a package update echo "rdiff-backup hold"|dpkg --set-selections How to start some of ubuntu's daemons in fluxbox gnome-volume-manager & gnome-power-manager & gnome-settings-daemon & sleep 1 You need the sleep in order to get the GTK theme, etc, loaded before Fluxbox, GKrellm, etc. How to build DEBs To do this properly (for distribution) you should set up a chroot. See the docs on Ubuntu's wiki. This info is coming from: http://www.debian.org/doc/manuals/maint-guide/index.en.html#contents sudo apt-get install dpkg-dev file gcc g++ libc6-dev make patch perl autoconf dh-make fakeroot autotools-dev automake14 I'll be working in ~/scratch. Put your source tarball here and untar it. dh_make -e youremail@somehost.com -f ../some-app-0.1.tar.gz Now's when you edit all the files in debian/ When you're satified: dpkg-buildpackage -rfakeroot How to set up a chroot sudo apt-get install debootstrap dchroot sudo mkdir /var/chroot Edit /etc/dchroot.conf, and append: /var/chroot sudo debootstrap --variant=buildd --arch i386 dapper /var/chroot/ http://archive.ubuntu.com/ubuntu/ sudo cp /etc/resolv.conf /var/chroot/etc/resolv.conf sudo cp /etc/apt/sources.list /var/chroot/etc/apt/sources.list sudo chroot /var/chroot/ apt-get update apt-get install wget debconf devscripts gnupg locale-gen en_AU.UTF-8 tzinfo Extra steps for non-root use: sudo cp /etc/passwd /var/chroot/etc/ sudo sed 's/\(^:*\):^:*:/\1:*:/' /etc/shadow | sudo tee /var/chroot/etc/shadow sudo cp /etc/group /var/chroot/etc/ sudo cp /etc/hosts /var/chroot/etc/ sudo cp /etc/sudoers /var/chroot/etc/ sudo chroot /var/chroot/ dpkg-reconfigure passwd passwd apt-get install sudo exit Then set your in /var/chroot/etc/debian_chroot. And create your home directory (or bind-mount it). To chroot: dchroot -d dchroot -d 'command' How to create a repository Quick and dirty. This doesn't handle distributing sources or signing packages. mkdir -p /var/www/apt/dists/dapper/main put your .debs in there. cd /var/www/apt/dists/dapper/main dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz cp Packages.gz dists/dapper/main/binary-i386/ Now create a release file: vim /var/www/apt/Release Archive: dapper Component: main Origin: n3il.com Label: n3il.com Architecture: i386 To use, add this to /etc/apt/sources.list: deb http://localhost/apt dapper main apt-get update =Debian (debian specific)= How to install x apt-get install x-window-system How to install from floppy You need 3 floppies: *boot.img *root.img *net-drivers.img =CentOS= How to install kernel headers yum install kernel-devel How to build RPMS *Sources go in /usr/src/redhat/SOURCES *Output goes in /usr/src/redhat/RPMS/i386/ yum install rpmbuild rpmbuild -ba -.spec How to use grouplists yum grouplist yum groupinstall "GNOME Desktop Environment" How to install asterisk CentOS has the best asterisk packages! *Put this in /etc/yum.conf: atrpms name=RHEL 5 - i386 ATrpms baseurl=http://dl.atrpms.net/el5-$basearch/atrpms/stable gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms gpgcheck=1 *Australian voices (do this each time you upgade): cd wget http://www.openvoice.com.au/free/OpenVoice-Free-1.3.tar.gz tar zxvf OpenVoice-Free-1.3.tar.gz /bin/cp -v OpenVoice-Free/au/* /var/lib/asterisk/sounds/ /bin/cp -v OpenVoice-Free/digits/au/* /var/lib/asterisk/sounds/digits Category:Browse